package com.ywj.activemq.jms;

import org.springframework.jms.annotation.JmsListener;
import org.springframework.messaging.handler.annotation.SendTo;
import org.springframework.stereotype.Component;

//@Component
//public class MessageListener {
//
//    @JmsListener(destination = "order.queue.message")
//    private void receive(String message){
//        System.out.println("自动接收消息：" + message);
//    }
//}


//扩展监听器功能，@SendTo将消息处理完继续发送、继续处理
@Component
public class MessageListener {

    @JmsListener(destination = "order.queue.message")
    @SendTo("other.queue")
    private String receive(String message){
        System.out.println("自动接收到order.queue.message消息："+ message);
//        注意是将此方法的返回值返回到 新的队列中
        return message;
    }

    @JmsListener(destination = "other.queue")
    private void  receiveOther(String message){
        System.out.println("接收到other.queue继续发送的消息：" + message);
    }
}



